package kgame5.pbe.atlantic.comp {
	import kgame5.pbe.atlantic.event.ViewEvent;
	import kgame5.pbe.atlantic.vo.EntityVO;
	import kgame5.pbe.engine.components.AnimatedComponent;

	/**
	 * @author max
	 * 2010-12-13
	 */
	public class ViewComp2D extends AnimatedComponent{
		
		private var entVO:EntityVO;
		
		public function ViewComp2D(entVO:EntityVO){
			this.entVO=entVO;
		}
		
		override public function onFrame(deltaTime:Number):void
        {
        	
		}

		
		
		//跳转到某个制定动画并播放
		public function playAnim(animName:String,frame:int=0):void{
			
		}
		
		//切换到另一种样子
		public function changePeriod(p:int):void{
			
		}
		
		//改变方向
		public function changeDir(dir:int):void{
			
		}
		
		
		//对外发送事件
		public function sendEvent(name:String,data:Object=null):void{
			owner.eventDispatcher.dispatchEvent(new ViewEvent(name,data));
		}
		
		//实用的两个函数
		public function sendClickEvent(x:int,y:int):void{
			sendEvent(ViewEvent.CLICK,{x:x,y:y});
		}
		public function sendEndOFrameEvent(animName:String):void{
			sendEvent(ViewEvent.EOF,animName);
		}
	}
}

//=========================================================
//private var mc:MovieClip;//保持的node中的一个引用，属于快捷方式
//override protected function onAdd():void{
//			super.onAdd();
//			
//			PBE.viewManager.addNode(node);
//			
//			//测试用暂时关闭
//			var param:ViewParam=new ViewParam();//ParamsManager.getInstance().getViewParam(entVO.viewParamID);
//			param.url="Atlantic.swf";
//			
//			PBE.resourceManager.load(param.url, SWFResource,onLoadOK,onLoadFail);
//			
//			
//		}
//		override protected function onRemove():void{
//			super.onRemove();
//			
//			PBE.viewManager.removeNode(node);
//		}
//private function onLoadOK(r:SWFResource):void{
//			
//			var c:Class=r.getAssetClass("MyMc_PlantCorn");//PlantCorn
//			T.p("onLoadOK",c);
//			mc=new c() as MovieClip;
//			
//			(node.getDO() as Sprite).addChild(mc);
//			
//			mc.stop();
//			
//			mc.addEventListener(MouseEvent.CLICK, onClick);
//		}
//		
//		private function onClick(e:MouseEvent):void{
//			if(mc.currentFrame==mc.totalFrames){
//				mc.gotoAndStop(1);
//			}else{
//				mc.nextFrame();
//			}
//		}
//private function onLoadFail(r:SWFResource):void{
//			
//		}